package com.j.lemon.learn.flink.dataset;

import com.j.lemon.learn.flink.WordCount;
import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.api.java.DataSet;
import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.api.java.tuple.Tuple2;

/**
 * 返回数据集前n个元素
 * @author lijunjun
 */
public class FirstNOperator {
    public static void main(String[] args) throws Exception {
        ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
        DataSet<WordCount> dataSet = env.fromElements(
                new WordCount("zhangsan", 1),
                new WordCount("lisi", 2),
                new WordCount("lisi", 3))
                .first(2);
        dataSet.print();


    }
}
